class SchemaTool:
    def __init__(self, conn, db_type):
        self.conn = conn
        self.db_type = db_type

    def list_tables(self):
        cursor = self.conn.cursor()
        if self.db_type == 'sqlite':
            cursor.execute("SELECT name FROM sqlite_master WHERE type='table'")
            return [row[0] for row in cursor.fetchall()]
        elif self.db_type == 'mysql':
            cursor.execute("SHOW TABLES")
            return [row[0] for row in cursor.fetchall()]
        elif self.db_type == 'postgresql':
            cursor.execute("SELECT table_name FROM information_schema.tables WHERE table_schema='public'")
            return [row[0] for row in cursor.fetchall()]
        else:
            return []

    def list_columns(self, table_name):
        cursor = self.conn.cursor()
        if self.db_type == 'sqlite':
            cursor.execute(f"PRAGMA table_info({table_name})")
            return [row[1] for row in cursor.fetchall()]
        elif self.db_type == 'mysql':
            cursor.execute(f"DESCRIBE {table_name}")
            return [row[0] for row in cursor.fetchall()]
        elif self.db_type == 'postgresql':
            cursor.execute(f"""
                SELECT column_name FROM information_schema.columns 
                WHERE table_name = '{table_name}'
            """)
            return [row[0] for row in cursor.fetchall()]
